﻿var setting = {
    check: {
        chkboxType: { "Y": "ps", "N": "ps" },
        enable: true
    },
    data: {
        simpleData: {
            enable: true
        }
    }
};


//备选专家列表，以JSON方式保存
var expertBX = new Object;
expertBX.expertId = "";
expertBX.expertName = "";
expertBX.expertPhone = "";
expertBX.expertProfession = "";
expertBX.expertUnit = "";
expertBX.expertTitle = "";

//已选专家列表，以JSON方式保存
var extractDetailRecord = new Object;
extractDetailRecord.expertId = "";
extractDetailRecord.expertName = "";
extractDetailRecord.expertPhone = "";
extractDetailRecord.expertProfession = "";
extractDetailRecord.expertUnit = "";
extractDetailRecord.expertTitle = "";
extractDetailRecord.extractIsOK = "N";
extractDetailRecord.extractDescribe = "";
extractDetailRecord.extractType = "";

//备选专家类列表
var expertBXs = new Array();

//备选专家ID
var expertBXn_IDs = new Array();

//已选专家ID列表
var expertYX_IDs = new Array();

//已抽取成功的抽取记录列表
var extractDetails = new Array();

//剔出已选专家之后的备选专家列表，用于滚动选择
var expertBXs_DO = new Array();

//用于滚动选择的备选IDs
var expertBXn_IDs_DO = new Array();

var expertBXs_ID,   //备选专家ID
        expertBXs_NAME, //备选专家姓名
        expertBXs_PROFESSIONAL, //备选专家专业made ,
        expertBXs_TITLE,    //备选专家职称
        expertBXs_UNIT;      //备选专家工作单位

//抽取关联的项目列表
var extractProjects;

//当前抽取选项的专业列表、分类列表
var optionProfessions,    //抽取选项的专家抽取专业
    optionCategorys;      //抽取选项的专家抽取分类


//获取专家分类树形
function getCategorys(str_url) {
    $.ajax({
        type: "GET",
        url: str_url,
        dataType: "json",
        success: function (data) {
            //初始化专业专家的所属分类
            $.fn.zTree.init($("#treeCategory"), setting, data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(textStatus);
        }
    });
}

//获取项目列表
function getProjects(str_url) {
    $.ajax({
        url: str_url,
        type: "POST",
        dataType: "json",
        // query will be the param used by your action method
        data: { keyword: $("#queryStringProject").val() },
        success: function (data) {
            var listHtml = "";

            //循环取json中的数据,并呈现在列表中
            $.each(data, function (i) {
                listHtml += " <div style='margin: 10px;'>";
                listHtml += " <input type='checkbox'";
                listHtml += " name='ProjectIDs'";
                listHtml += " id=" + data[i].projectId;
                listHtml += " value=" + data[i].projectId;
                listHtml += " style=border:none;/>";
                listHtml += "<label for=" + data[i].projectId;
                listHtml += ">[" + data[i].projectCode + "]" + data[i].projectName + "</label></div>";
            });

            $("#project_list").html(listHtml);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(textStatus);
        }
    });
}

//获取项目列表
function getStep1Projects(str_url) {
    $.ajax({
        url: str_url,
        type: "POST",
        dataType: "json",
        // query will be the param used by your action method
        data: { keyword: $("#queryStringProject").val() },
        success: function (data) {
            var listHtml = "";

            //循环取json中的数据,并呈现在列表中
            $.each(data, function (i) {
                listHtml += " <p style='margin: 10px;'>";
                listHtml += " <input type='checkbox'";
                listHtml += " name='selectedProjectIDs'";
                listHtml += " id=" + data[i].projectId;
                listHtml += " value=" + data[i].projectId;
                listHtml += " style=border:none;/>";
                listHtml += "<label for=" + data[i].projectId;
                listHtml += ">[" + data[i].projectCode + "]" + data[i].projectName + "</label></p>";
                for (var x = 0; x < data[i].projectExtractRecords.length; x++) {
                    listHtml += "<p style='margin: 5px 0px 5px 20px; text-indent: -1em;'>";
                    listHtml += "<a href='javascript:deleteExtract(" + '"' + data[i].projectExtractRecords[x].recId + '"' + ")' title='删除'><span class='ui-icon ui-icon-circle-close' style='float: left; margin-right: 1em;'></span></a>";
                    listHtml += "<a href='doExtract?extractID=" + data[i].projectExtractRecords[x].recId + "' style='color: #444;' title='操作'>[" +
                    data[i].projectExtractRecords[x].recOPuserName + ":" +
                    data[i].projectExtractRecords[x].recDate + "]" +
                    data[i].projectExtractRecords[x].recTitle;
                    listHtml += "</a></p>";
                }
            });

            $("#project_list").html(listHtml);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(textStatus);
        }
    });
}

//根据抽取选项的专业分类以及专业名称，查询专家备选列表
function getExpertsBX() {
    if (getExtractOption()) {
        var strP = "", strC = "";

        //根据抽取选项，生成专业查询字符串
        if (optionProfessions && optionProfessions.length > 0) {

            for (var i = 0, l = optionProfessions.length; i < l; i++) {
                if (optionProfessions[i] != "") {
                    if (strP == "") {
                        strP = optionProfessions[i];
                    } else {
                        strP += "," + optionProfessions[i];
                    }
                }
            }
        }

        //生成分类查询字符串
        if (optionCategorys && optionCategorys.length > 0) {
            for (var i = 0, l = optionCategorys.length; i < l; i++) {
                if (optionCategorys[i] != "") {
                    if (strC == "") {
                        strC = optionCategorys[i];
                    } else {
                        strC += "," + optionCategorys[i];
                    }
                }
            }
        }

        $.ajax({
            url: strUrlgetExpertsBX,
            type: "POST",
            dataType: "json",
            data: { kwProfessions: strP, kwCategoryIDs: strC },
            success: function (data) {
                expertBXs.length = 0;

                $.each(data, function (i) {
                    //保存备选专家记录（总）
                    var exp = new Object;
                    exp.expertId = data[i].expertId;
                    exp.expertName = data[i].expertName;
                    exp.expertPhone = data[i].expertPhone;
                    exp.expertProfession = data[i].expertProfession;
                    exp.expertUnit = data[i].expertUnit;
                    exp.expertTitle = data[i].expertTitle;
                    expertBXs.push(exp);
                });

                if (expertBXs.length > 0) {
                    //逐一循环备选专家（总）列表的记录，如果当前备选专家不在已选专家中，添加到用于滚动的备选专家中
                    expertBXs_DO.length = 0;
                    for (i = 0; i < expertBXs.length; i++) {
                        var isYX = false;
                        if (typeof (expertYX_IDs) != "undefined" && expertYX_IDs.length > 0) {
                            for (j = 0; j < expertYX_IDs.length; j++) {
                                if (expertBXs[i].expertId == expertYX_IDs[j]) {
                                    isYX = true;
                                    break;
                                }
                            }
                        }

                        //当前专家记录不在已选专家ID列表中，添加到真正滚动的备选专家数组中
                        if (!isYX) expertBXs_DO.push(expertBXs[i]);
                    }

                    //循环用于滚动选择的备选专家列表，交叉备选专家ID，生成备选专家ID列表
                    expertBXn_IDs_DO.length = 0;
                    for (i = 0; i < expertBXs_DO.length; i++) {
                        for (j = 0; j < expertBXn_IDs.length; j++) {
                            if (expertBXs_DO[i].expertId == expertBXn_IDs[j]) {
                                expertBXn_IDs_DO.push(expertBXs_DO[i].expertId);
                                break;
                            }
                        }
                    }
                }

                //显示专家列表
                showExpertBX();

                return true;
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alertMSG("获取专家列表错误！错误代码如下：<br/>" + textStatus);
                return false;
            }
        });
        return true;
    } else {
        alertMSG("获取抽取选项错误！");
        return false;
    }
}

//显示备选专家列表
function showExpertBX() {
    if (expertBXs) {
        var listHtml = "";
        $.each(expertBXs_DO, function (i) {
            listHtml += "<div style='margin: 5px; border-bottom: 1px dotted gray;'>";
            listHtml += "<span style='font-size:2em;'><strong>";
            listHtml += expertBXs_DO[i].expertName;
            listHtml += "</strong></span>";
            listHtml += "<span> " + expertBXs_DO[i].expertPhone + "；</span>";
            listHtml += "<span> " + expertBXs_DO[i].expertProfession + "；</span>";
            listHtml += "<span> " + expertBXs_DO[i].expertUnit + "；</span>";
            listHtml += "<span> " + expertBXs_DO[i].expertTitle + "；</span>";
            listHtml += "</div>";
        });

        $("#expertBX").html(listHtml);
    }
}

//获取专家备选列表1
function getExpertsBXn() {
    var strP = ""
    if (extractProjects && extractProjects.length > 0) {
        for (var i = 0, l = extractProjects.length; i < l; i++) {
            if (extractProjects[i] != "") {
                if (strP == "") {
                    strP = extractProjects[i];
                } else {
                    strP += "," + extractProjects[i];
                }
            }
        }
    }

    $.ajax({
        url: strUrlgetExpertsBXn,
        type: "POST",
        dataType: "json",
        data: { kwProjectIds: strP },
        success: function (data) {
            expertBXn_IDs.length = 0;

            $.each(data, function (i) {
                //保存记录
                expertBXn_IDs.push(data[i]);
            });

            //接着获取备选记录
            getExpertsBX();
            return true;
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alertMSG("获取专家列表错误！错误代码如下：<br/>" + textStatus);
            return false;
        }
    });
    return true;
}

function getExperts() {
    //判断关联项目是否包含
    if (checkProject()) {

    } else {
        //返回没有选择项目的错误信息
        alertMSG("关联的项目未选择！");
        return;
    }

    //获取备选n，生成备选记录的同时，查询以及处理备选滚定专家列表
    if (getExpertsBXn()) {
        //
    } else {
        //返回专家列表选择失败的错误信息
        alertMSG("获取备选专家列表失败！");
        return;
    }
}

//抽取的备选专家滚动状态
var i = 0,      //当前滚动的索引
		tmp,    //临时变量
		isScroll = false;   //是否处于滚动状态标识

//开始备选专家姓名的滚动，时间间隔e，单位毫秒
function startxx(e) {
    if (typeof (expertBXs_DO) == "undefined" ||
        typeof (expertBXs_DO) == "null" ||
        expertBXs_DO == null ||
        expertBXs_DO == "" ||
        expertBXs_DO.length == 0) {
        alertMSG("备选专家数量为0。不能进行随机抽取操作。");
        isScroll = false;
        return;
    }

    tmp = setInterval(function () {
        if (i < expertBXs_DO.length) {
            $('#expertBXLB').html(expertBXs_DO[i].expertName);
            i++;
        } else {
            i = 0;
            $('#expertBXLB').html(expertBXs_DO[i].expertName);
            i++;
        }
    }, e);

    //设置状态
    $("#doExtractIcon").removeClass("ui-icon-play");
    $("#doExtractIcon").addClass("ui-icon-pause");
    $("#doExtractCaption").html("停止");
}

//停止抽取滚动，获取当前的专家记录
function stopxx() {
    tmp = clearInterval(tmp);

    //获取一个专家信息
    extractOneExpert();
}

//在备选专家列表中抽取一个专家
function extractOneExpert() {
    var selected_id = "";

    //在备选专家ID列表中选出一个
    if (expertBXn_IDs_DO.length > 0) {
        //随机获取一个ID记录
        selected_id = expertBXn_IDs_DO[Math.floor(Math.random() * expertBXn_IDs_DO.length)];
    } else {
        selected_id = expertBXs_DO[Math.floor(Math.random() * expertBXs_DO.length)].expertId;
    }

    if (selected_id != "") {
        try {
            //循环专家备选列表，获取当前选中的专家记录，设置界面
            var selected_expert = null;
            for (var j = 0; j < expertBXs_DO.length; j++) {
                if (selected_id == expertBXs_DO[j].expertId) {
                    selected_expert = expertBXs_DO[j];
                    break;
                }
            }

            //设置界面
            if (selected_expert != null) {
                $("#SelectedExpertId").val(selected_expert.expertId);
                $("#expertBXLB").html(selected_expert.expertName);
                $("#SelectedExpertName").html(selected_expert.expertName);
                $("#SelectedExpertDescribe").html("同意参加评审。");
                $("#SelectedExpertInfo").html(selected_expert.expertPhone + "；" +
                selected_expert.expertUnit + "；" +
                selected_expert.expertTitle + "；" +
                selected_expert.expertProfession + "；");
            }

            //禁止“开始”按钮点击，保存当前抽取记录后，再启用
            $("#doExtract").attr('disabled', 'disabled');
        } catch (e) {
            alertMSG("抽取错误！请重新抽取。</ br>错误代码：" + e.Message);
            return;
        }
    } else {
        alertMSG("抽取错误！请重新抽取。");
        return;
    }
}

//抽取一个专家
function extract() {
    isScroll = !isScroll;

    if (isScroll) {
        startxx(200);

    } else {
        stopxx();
    }
}

//数组删除指定位置的自定义方法
Array.prototype.del = function (n) {  //n表示第几项，从0开始算起。
    //prototype为对象原型，注意这里为对象增加自定义方法的方法。
    if (n < 0)  //如果n<0，则不进行任何操作。
        return this;
    else
        return this.slice(0, n).concat(this.slice(n + 1, this.length));
    /*
    concat方法：返回一个新数组，这个新数组是由两个或更多数组组合而成的。
      　　　　　　这里就是返回this.slice(0,n)/this.slice(n+1,this.length)
     　　　　　　组成的新数组，这中间，刚好少了第n项。
    slice方法： 返回一个数组的一段，两个参数，分别指定开始和结束的位置。

    //测试代码
    var test=new Array(0,1,2,3,4,5);
    test=test.del(3);  //从0算起，这里也就是删除第4项。
    alert(test);

    */
}


//保存当前抽取的专家记录到已选专家列表
function saveThisExtractDetail() {
    var thisSelectedExpertID = $('#SelectedExpertId').val();

    if (typeof (thisSelectedExpertID) != "undefined" && thisSelectedExpertID.length > 0) {
        //判断抽取结果描述是否输入，如果没有，提示要求输入
        if ($("#SelectedExpertDescribe").val() == null || $("#SelectedExpertDescribe").val() == "undefined" || $("#SelectedExpertDescribe").val() == "") {
            alertMSG("抽取结果描述没有输入！");
        } else {
            //添加当前选择的专家ID到已选专家ID列表
            expertYX_IDs.push(thisSelectedExpertID);

            //添加抽取记录
            var thisExtractDetail = new Object;
            thisExtractDetail.expertId = thisSelectedExpertID;
            thisExtractDetail.expertName = "";
            thisExtractDetail.expertPhone = "";
            thisExtractDetail.expertProfession = "";
            thisExtractDetail.expertUnit = "";
            thisExtractDetail.expertTitle = "";
            thisExtractDetail.extractIsOK = "N";
            thisExtractDetail.extractDescribe = "";
            thisExtractDetail.extractType = "";

            //设置抽取记录的类型，是专业专家还是商务专家
            var val = $('input:radio[name="extracOption"]:checked').val();
            if (val == null) {
                alert("请首先选择抽取专家类型!");
                return false;
            }
            else {
                if (val == "ZY") {
                    //专业专家
                    thisExtractDetail.extractType = "专业评委";
                } else {
                    //商务专家
                    thisExtractDetail.extractType = "商务评委";
                }
            }

            //设置抽取记录的是否参加评标
            if ($("#SelectedExpertIsOK").attr("checked") == true || $("#SelectedExpertIsOK").attr("checked") == "checked") {
                thisExtractDetail.extractIsOK = "Y";
            } else {
                thisExtractDetail.extractIsOK = "N";
            }

            if ($("#SelectedExpertDescribe").html() == null ||
            $("#SelectedExpertDescribe").html() == "undefined" ||
            $("#SelectedExpertDescribe").html().length == 0) {
                thisExtractDetail.extractDescribe = "";
            } else {
                thisExtractDetail.extractDescribe = $("#SelectedExpertDescribe").html();
            }


            //备选专家记录列表删除当前选择的记录
            for (i = 0; i < expertBXs_DO.length; i++) {
                if (expertBXs_DO[i].expertId == thisSelectedExpertID) {
                    //设置抽取记录的专家信息
                    thisExtractDetail.expertName = expertBXs_DO[i].expertName;
                    thisExtractDetail.expertPhone = expertBXs_DO[i].expertPhone;
                    thisExtractDetail.expertProfession = expertBXs_DO[i].expertProfession;
                    thisExtractDetail.expertUnit = expertBXs_DO[i].expertUnit;
                    thisExtractDetail.expertTitle = expertBXs_DO[i].expertTitle;

                    expertBXs_DO = expertBXs_DO.del(i);

                    break;
                }
            }

            //备选专家记录列表删除当前选择的记录
            for (i = 0; i < expertBXn_IDs_DO.length; i++) {
                if (expertBXn_IDs_DO[i] == thisSelectedExpertID) {
                    expertBXn_IDs_DO = expertBXn_IDs_DO.del(i);
                    break;
                }
            }

            //生成的抽取记录添加抽取记录列表
            extractDetails.push(thisExtractDetail);

            //初始化界面
            initExtractForm();

            //输出已选专家列表
            listextractDetails();
        }
    } else {
        alertMSG("保存当前选择的专家信息错误。请首先随机抽取一个专家。");
    }
}

//初始化抽取的界面
function initExtractForm() {
    //设置按钮状态
    $("#doExtract").removeAttr('disabled');
    $("#doExtractIcon").removeClass("ui-icon-pause");
    $("#doExtractIcon").addClass("ui-icon-play");
    $("#doExtractCaption").html("开始");

    //设置选中专家的信息
    $('#SelectedExpertId').val("");
    $("#expertBXLB").html("随机选取");
    $("#SelectedExpertName").html("");
    $("#SelectedExpertInfo").html("");

    $("#SelectedExpertIsOK").attr('checked', 'true');
    $("#SelectedExpertDescribe").val("");

    //启用滚动按钮
    $("#doExtract").removeAttr('disabled');
}

//输出已选专家列表到界面
function listextractDetails() {
    var strHTML = "";
    for (i = 0; i < extractDetails.length; i++) {
        //输出当前抽取记录专家的信息
        var strTMP = '<li style="padding: 5px; margin-bottom: 20px;">';


        //输出当前抽取记录专家的抽取信息
        if (extractDetails[i].extractIsOK == "Y") {
            strTMP += '<p><span style="margin-right: .3em; font-size: 1.3em; ">[' + extractDetails[i].extractType + ']' + extractDetails[i].expertName + '</span>' +
            '<span style="margin-right: .3em; padding-top: .3em;">' + '：' +
            extractDetails[i].expertPhone + '；' +
            extractDetails[i].expertUnit + '；' +
            extractDetails[i].expertTitle + '；' +
            extractDetails[i].expertProfession + '；</span></p>';

            strTMP +=
            '<p><span style="float:left; margin-right: .3em; padding-top: .3em; color: blue;">参加评标；</span>';
            strTMP += '<span><a href="';
            strTMP += 'javascript:delectThisExtractDetail(';
            strTMP += "'";
            strTMP += extractDetails[i].expertId;
            strTMP += "'";
            strTMP += ');"><span class="ui-icon ui-icon-trash" style="float: left;"></span>删除</a></span></p>';

            strTMP += '<p><span style="float:left; margin-right: .3em; padding-top: .3em; color: #444;">' + extractDetails[i].extractDescribe + '</span></p>';
        } else {
            strTMP += '<p><span style="margin-right: .3em; font-size: 1.3em; color: #444; ">[' + extractDetails[i].extractType + ']' + extractDetails[i].expertName + '</span>' +
            '<span style="margin-right: .3em; padding-top: .3em; color: #444;">' + '：' +
            extractDetails[i].expertPhone + '；' +
            extractDetails[i].expertUnit + '；' +
            extractDetails[i].expertTitle + '；' +
            extractDetails[i].expertProfession + '；</span></p>';

            strTMP +=
            '<p><span style="float:left; margin-right: .3em; padding-top: .3em; color: red;">不参加评标；</span>';
            strTMP += '<span><a href="';
            strTMP += 'javascript:delectThisExtractDetail(';
            strTMP += "'";
            strTMP += extractDetails[i].expertId;
            strTMP += "'";
            strTMP += ');"><span class="ui-icon ui-icon-trash" style="float: left;"></span>删除</a></span></p>';

            strTMP += '<p><span style="float:left; margin-right: .3em; padding-top: .3em; color: #444;">' + extractDetails[i].extractDescribe + '</span></p>';
        }

        strTMP += '</li>';
        strHTML += strTMP;
    }

    $("#extractDetails").html(strHTML);
}


function confirmsaveThisExtract() {
    $("#thisPageMsg").html("是否要保存当前抽取记录？");
    $("#thisPageMsg").dialog({
        modal: true,
        buttons: {
            "保存": function () {
                saveThisExtract();
            },
            "取消": function () {
                $(this).dialog("close");
            }
        }
    });
}

//保存当前抽取记录
function saveThisExtract() {
    //设置标题
    $("#extractRecord_Title").val($("#extractRecord_Title").val());

    //判断是否有关联项目列表
    if ($("#selectedProjectIDs").val() == null || $("#selectedProjectIDs").val() == "undefined" || $("#selectedProjectIDs").val() == "") {
        alertMSG("项目关联失败，提交数据错误。");
        return false;
    }

    var strTEMP;

    //拼凑抽取详细记录的是否参加列表
    strTEMP = "";
    for (i = 0; i < extractDetails.length; i++) {
        if (strTEMP == "") {
            strTEMP = extractDetails[i].extractIsOK;
        } else {
            strTEMP += "," + extractDetails[i].extractIsOK;
        }
    }
    $("#extractRecord_details_IsOK").val(strTEMP);

    //拼凑抽取详细记录的抽取结果描述列表
    strTEMP = "";
    for (i = 0; i < extractDetails.length; i++) {
        if (strTEMP == "") {
            strTEMP = extractDetails[i].extractDescribe;
        } else {
            strTEMP += "," + extractDetails[i].extractDescribe;
        }
    }
    $("#extractRecord_details_Describe").val(strTEMP);

    //拼凑抽取详细记录的抽取类型（专业、商务）列表
    strTEMP = "";
    for (i = 0; i < extractDetails.length; i++) {
        if (strTEMP == "") {
            strTEMP = extractDetails[i].extractType;
        } else {
            strTEMP += "," + extractDetails[i].extractType;
        }
    }
    $("#extractRecord_details_Type").val(strTEMP);

    //拼凑抽取详细记录的抽取结果专家ID列表
    strTEMP = "";
    for (i = 0; i < extractDetails.length; i++) {
        if (strTEMP == "") {
            strTEMP = extractDetails[i].expertId;
        } else {
            strTEMP += "," + extractDetails[i].expertId;
        }
    }
    $("#extractRecord_details_ExpertId").val(strTEMP);


    //提交表单
    $("#formOP").submit();
}

//删除指定ID的抽取记录
function deleteExtract(eid) {
    if (confirm("真的删除当前抽取记录吗？")) {
        $.ajax({
            url: strUrldeleteAExtract,
            type: "GET",
            dataType: "json",
            // query will be the param used by your action method
            data: { extractID: eid },
            success: function (data) {
                getStep1Projects(strUrlgetStep1Projects);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(textStatus);
            }
        });
    }
}

//删除指定专家ID的抽取结果记录
function delectThisExtractDetail(thisExpertId) {
    //删除抽取记录
    for (i = 0; i < extractDetails.length; i++) {
        if (extractDetails[i].expertId == thisExpertId) {
            //根据当前专家ID，查找备选专家列表，将找到的专家记录添加到滚动专家列表中
            for (idx = 0; idx < expertBXs.length; idx++) {
                if (expertBXs[idx].expertId == thisExpertId) {
                    //添加到专家滚动列表
                    var n = new Object;
                    n.expertId = expertBXs[idx].expertId;
                    n.expertName = expertBXs[idx].expertName;
                    n.expertPhone = expertBXs[idx].expertPhone;
                    n.expertProfession = expertBXs[idx].expertProfession;
                    n.expertUnit = expertBXs[idx].expertUnit;
                    n.expertTitle = expertBXs[idx].expertTitle;

                    expertBXs_DO.push(n);
                    break;
                }
            }

            /*
            //不需要恢复备选专家n滚动列表
            for (idx = 0; idx < expertBXn_IDs.length; idx++) {
            if (expertBXn_IDs[idx] == thisExpertId) {
            //添加到专家n滚动列表
            expertBXn_IDs_DO.push(thisExpertId);
            break;
            }
            }
            */

            //删除当前找到的抽取记录
            extractDetails = extractDetails.del(i);

            //刷新已抽取的列表
            initExtractForm();
            listextractDetails();

            break;
        }
    }

}

//判断并设置项目信息
function checkProject() {
    //1、获取关联项目ID
    var strP = $("#selectedProjectIDs").val();

    if (strP.length > 0) {
        //2、设置抽取关联项目数组
        extractProjects = strP.split(",");
        if (extractProjects.length > 0) {
            return true;
        } else {
            return false;
        }
    }
    else {
        return false;
    }
}

//获取抽取选项
function getExtractOption() {
    //按专家专业
    optionProfessions = $("#txtProfessional").val().split(",");

    //按专家分类
    var strC = "";
    var zTree = $.fn.zTree.getZTreeObj("treeCategory"),
            nodes = zTree.getCheckedNodes(true);
    for (var i = 0, l = nodes.length; i < l; i++) {
        if (!nodes[i].isParent) {
            if (strC == "") {
                strC = nodes[i].id;
            } else {
                strC += "," + nodes[i].id;
            }
        }
    }
    optionCategorys = strC.split(",");
    return true;
}

//Step1：获取勾选的项目IDs，提交网页至新建抽取记录页面
function step1NewExtractRecord() {
    try {
        //1、获取项目勾选信息
        var chbProjects = $("input[name='selectedProjectIDs']:checked");
        var strP = "";
        for (var i = 0, l = chbProjects.length; i < l; i++) {
            if (chbProjects[i].checked) {
                if (strP == "") {
                    strP = chbProjects[i].id;
                } else {
                    strP += "," + chbProjects[i].id;
                }
            }
        }

        if (strP.length <= 0) {
            alertMSG("关联项目没有选择。");
        }
        else {
            $("#selectedProjectIDs").val(strP);
            $("#formOP").submit();
        }
    } catch (e) {
        alertMSG("项目获取失败，提交数据错误。");
    }
}

//doExtract：获取指定抽取记录ID的抽取结果详细记录
function getExtractDetails(ExtractID) {
    $.ajax({
        url: strUrlgetExtractDetails,
        type: "POST",
        dataType: "json",
        // query will be the param used by your action method
        data: { extractID: ExtractID },
        success: function (data) {
            $("#DataTemplate_Details").html("");
            //填充关联项目表格
            $('#DataTemplate_Details').tmpl(data).appendTo('#tableDetails');
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(textStatus);
        }
    });
}
